<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS正则演示</title>
<#include "/include/common.ftl">
</head>
<body>
<input type="text" id="idPhone">
<input type="button" value="验证" id="validate">
</body>
<script type="text/javascript">

    $(function ($) {
        $("#validate").click(function () {
            if (!checkPhone()) {
                alert("请输入正确号码");
            }
        });
    });

    function checkPhone() {
        var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
        var isMob = /^((\+?86)|(\+86))?(13[012356789][0-9]{8}|15[012356789][0-9]{8}|18[02356789][0-9]{8}|147[0-9]{8}|1349[0-9]{7})$/;
        var value = $("#idPhone").val().trim();
        if (isMob.test(value) || isPhone.test(value)){
            return true;
        }
        else {
            return false;
        }
    }
</script>
</html>